package com.wrial.face.tencent;
/*
 * @Author  Wrial
 * @Date Created in 21:04 2020/8/23
 * @Description
 */

import java.awt.*;
import java.util.Scanner;

public class NumSum {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        for (int i = 0; i < T; i++) {
            String temp = scanner.next();
            int sum = 0;
            for (int i1 = 0; i1 < temp.length(); i1++) {
                sum += temp.charAt(i1) - '0';
            }
            System.out.println(sum);
        }

    }
}
